package com.whq.common;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class InetAddressUtil {
	private static final Logger LOGGER = LoggerFactory.getLogger(InetAddressUtil.class);
	
	public static String getLocalIp()  {
		InetAddress addr = null;
		try {
			addr = InetAddress.getLocalHost();
		} catch (UnknownHostException e) {
			LOGGER.error("get local host ip exception: ", e);
		}
		if ( (addr != null) && (addr.getHostAddress() != null) ) {
			return addr.getHostAddress().toString();
		} else {
			return "";
		}
	}
}
